package main

import (
	"flag"
	"log"
	"berry-tv/config"
	"berry-tv/file"
	"berry-tv/server"
)

func main() {
	var (
		tomlFile string
		tomlHelp bool
	)

	flag.StringVar(&tomlFile, "c", "./config/config.toml", "toml config file")
	flag.BoolVar(&tomlHelp, "toml", false, "help toml")
	flag.Parse()

	if !file.Exist(tomlFile) {
		log.Printf("not found config file: %v\n", tomlFile)
		return
	}

	log.Println("config:", tomlFile)
	conf := config.ParseToml(tomlFile)

	server.Run(conf.Server.Addr, conf.Server.Port, conf.Database.Path, conf.Media.Roots)
}
